#include "rclcpp/rclcpp.hpp"
#include "base_interfaces_demo/msg/student.hpp"
using std::placeholders::_1;
using base_interfaces_demo::msg::Student;
class ListenerStu :public rclcpp::Node
{
public:
    ListenerStu():Node("listener_stu_node_cpp")
    {
        RCLCPP_INFO(this->get_logger(),"订阅节点已创立！");
        _subscripthon=this->create_subscription<Student>
        ("chatter",10,std::bind(&ListenerStu::topic_callback,this,_1));
    }
private:
    void topic_callback(const Student &msg) const
    {
        RCLCPP_INFO(this->get_logger(),"订阅的消息是：姓名：%s,年龄：%d岁,身高：%.2f米",msg.name.c_str(),msg.age,msg.height);
    }    
    std::shared_ptr<rclcpp::Subscription<Student>>_subscripthon;
};
int main(int argc,char*argv[])
{
    rclcpp::init(argc,argv);
    rclcpp::spin(std::make_shared<ListenerStu>());
    rclcpp::shutdown();
    return 0;
}